package org.naivecoders.ai.functions;

import org.naivecoders.ai.types.MaybeBowl;

public class NorCondition extends AbstractCondition {
	
	public NorCondition(AbstractFunction... inputs) {
		super(inputs);
	}

	@Override
	public MaybeBowl evaluate() {
		final AbstractCondition c1 = getInput(0);
		final AbstractCondition c2 = getInput(1);
		
		return !(c1.evaluateCondition() || c2.evaluateCondition())?
				MaybeBowl.SOMETHING: MaybeBowl.NOTHING;
	}
	
	public static AbstractCondition or(AbstractCondition cnd1, AbstractCondition cnd2){
		final AbstractCondition l = new NorCondition(cnd1, cnd2);
		final AbstractCondition r = new NorCondition(cnd1, cnd2);
		return new NorCondition(l,r);
	}
	
	public static AbstractCondition and(AbstractCondition cnd1, AbstractCondition cnd2){
		final AbstractCondition l = new NorCondition(cnd1, cnd1);
		final AbstractCondition r = new NorCondition(cnd2, cnd2);
		return new NorCondition(l,r);
	}

}
